<?php
require_once 'includes/config.php';
require_once 'includes/functions.php';
require_once 'includes/class.phpmailer.php';

//form submit action
if(!empty($_POST['submit']))
{
   $exe_code=mysql_query("SELECT * FROM tb1_referral_code WHERE ref_code='".$_POST['ref_code']."'") or die(mysql_error());
   $num_code=mysql_num_rows($exe_code);
   if($num_code>0)
   {
	   header("location:index.php?registerWholeseller");
   }
   else
   {
	   $msg="<font color='#FF0000'>Invalid Referral Code. Try Again!</font>";
   }
}
?>

<div id='panel'>
<form name="frmRegisterWholeseller" id="frmRegisterWholeseller" method="post" action="" onSubmit="return validateForm()">
<input type="hidden" name="registerMerchantKey" id="registerMerchantKey" />
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
	<td>
	<div class="releftbox_out">
	<div class="releftbox_top"></div>
	<div class="releftbox_repeat">
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
	  <tr>
		<td>
			<div id="messageAreaTop" style="margin:10px 0px 10px 20px; float:left;"><font color="#0000FF"><strong>For registration you have to enter correct referral code.</strong></font></div><br>
			<div id="messageAreaTop" style="margin:10px 0px 10px 20px; float:left;"><?php if(isset($msg)) echo "<b>".$msg."</b>"; ?></div>
			
			<div class="blue_box">
				<div class="form_field_box">
					<label for="ref_code" id="lblref_code">Referral Code:</label>
					<span>
					
					<input type="text" name="ref_code" id="ref_code" value="<?php echo $_REQUEST['ref_code']?>" class="inputbg" style="width:150px;" />
					</span>
					</div>
					

			<div class="blue_box" style="text-align:left;">
				<input type="submit" name="submit" id="submit" value="Submit" class="sbmt_btn" />
			</div>
			<div id="messageAreaBottom" style="margin:10px 0px 10px 20px; float:left;"></div>		</td>
	  </tr>
  	</table>
	</div>
	<div class="releftbox_bot">&nbsp;</div>
	</div>
	
	</td>
  	</tr>
</table>

</form>
</div>
<script language="javascript" type="text/javascript">
function validateForm()
{
	var flag=0;
	if($('#ref_code').val()=='')
	{
		flag=flag+1;
		$('#lblref_code').css({'font-weight':'bold','color':'#FF0000'});
		return false;
	}
	else {
		$('#lblref_code').css({'font-weight':'normal','color':'#666666'});
	}
}
</script>